package com.t.plugin_code;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.annotation.NonNull;


// 原视频中是说也可以不继承activity，然后直接写方法，但是为了方便所以写上的。
public class BaseActivity extends Activity implements PluginInterface {

    // that  代表的是那个传入的activity的上下文。
    protected Activity that;


    @Override
    public void attach(Activity activity) {
        this.that = activity;
    }


    @Override
    public void setContentView(int layoutResID) {
        that.setContentView(layoutResID);
    }

    @Override
    public void setContentView(View view) {

        if (that == null) {
            super.setContentView(view);
        } else {
            that.setContentView(view);
        }
    }

    // 这个在1时21分的时候，出现的。
    // 但是这个注解是什么意思？？
    @SuppressLint("MissingSuperCall")
    @Override
    public void onStart() {
    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onStop() {
    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onDestroy() {
    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onPause() {
    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onResume() {
    }

    @SuppressLint("MissingSuperCall")
    @Override
    public void onCreate(Bundle savedInstanceState) {
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {

    }



    @Override
    public Intent getIntent() {
        return that.getIntent();
    }

    @Override
    public <T extends View> T findViewById(int id) {
        return that.findViewById(id);
    }

    @Override
    public ClassLoader getClassLoader() {
        return that.getClassLoader();
    }

    @NonNull
    @Override
    public LayoutInflater getLayoutInflater() {
        return that.getLayoutInflater();
    }

    @Override
    public void startActivity(Intent intent) {
        Intent m = new Intent();
        m.putExtra("className",intent.getComponent().getClassName());
        that.startActivity(m);
    }

    @Override
    public Resources getResources() {
        return that.getResources();
    }
}
